package org.pi.common.time

trait TimeApi {
	private var ticTime: Long = 0
	def tic(): Unit = { ticTime = System.currentTimeMillis() }
	def toc(): Int = (System.currentTimeMillis()-ticTime).toInt
	def toc(text: String): Unit = println(text+": "+toc()+" ms.")
	def ticToc(code: => Unit): Int = {
		tic
		code
		toc
	}
	def printlnTicToc(text: String)(code: => Unit): Unit = { 
		print("tic-toc '"+text+"': ")
		println("elapsed time = "+ticToc(code)+" ms.") 
	}
}

object Api extends TimeApi {
}
